var Charts = require('../../utils/wxcharts.js');
// pages/clxq/clxq.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    current: 0,
    list: [
      { name: '合约1081', duo: '多', hand: 5, time: '2018.10.17', price: '45,000.00', nowprice: '50,000.00', rise: -350.00 },
      { name: '合约1081', duo: '空', hand: 5, time: '2018.10.17', price: '45,000.00', nowprice: '50,000.00', rise: 289.00 },
      { name: '合约1082', duo: '多', hand: 16, time: '2018.10.18', price: '45,000.00', nowprice: '50,000.00', rise: -110.00 },
      { name: '合约1083', duo: '空', hand: 1, time: '2018.10.19', price: '45,000.00', nowprice: '50,000.00', rise: -300.00 },
      { name: '合约1084', duo: '空', hand: 5, time: '2018.10.20', price: '45,000.00', nowprice: '50,000.00', rise: 620.00 },
    ]
  },

  /**
  * 生命周期函数--监听页面显示
  */
  onShow: function () {
    var that = this;
    that.ZXT()
  },

  changeQX:function(e){
    var that = this;
    that.setData({
      current: parseInt(e.currentTarget.id)
    })
  },
  // changeCurrent:function(e){
  //   var that = this;
  //   that.setData({
  //     current: e.detail.current
  //   })
  // }
  ZXT: function () {
    new Charts({
      canvasId: 'lineCanvas',
      type: 'line',
      categories: ['01', '02', '03', '04', '05', '06', '07', '08'],
      series: [{
        name: '收益率',
        data: [-1, -2, 0.50, 1.50, -1.50, 0.35, -1.50, 3],
        format: function (val) {
          return val.toFixed(2);
        }
      }],
      yAxis: {
        format: function (val) {
          return val;
        },
        min: 0
      },
      width: 350,
      height: 200
    });
  }
})